home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE24
/
EX2.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-07-04
|
2KB
|
45 lines
#include <genstub.c>
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch ( LOWORD( wParam ) )
{
case IDM_TEST:
{ // Try to create 32K timers.
int i;
int iInterval = 500; // Start at 500 milliseconds
for (i=0; i<0x7fff; i++)
{
int result = SetTimer( hWnd, i+1, iInterval, NULL );
if ( !result ) // If we cannot create the timer.
{
TCHAR szErrMsg[128];
// KillTimer frees a timer for screen capture utility.
// This allows the message box to be captured. Note:
// timers are _system-wide_ resources.
KillTimer( hWnd, 1 );
wsprintf( szErrMsg,
"Cannot create timer %d", i + 1);
MessageBox( hWnd, szErrMsg, "Error", MB_OK );
break;
}
iInterval+=100;
}
}
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
return (NULL);
}